import http from './httpRequests'

//接口配置
//请求发送api
const getAPI = (url, params) => {
    return http.get(url, {
        params
    })
}
//响应发送api
const postAPI = (url, data) => {
    return http.post(url, data)
}

//全局api
const globalAPI = {
    login: '/login',
    logout: '/logout',
    password: '/sys/user/password',//密码修改接口
    allReole: '/sys/role/all',//获取所有角色
    allDept: '/sys/dept/all',//获取所有部门 
    allMenu: '/sys/menu/all',//获取所有菜单
}
//首页api
const homeAPI = {
    index: '/userinfo',//首页数据接口
    indexTab: '/server/list',//首页医疗服务记录 

    getHomeAPI(params) {
        return getAPI(this.index, params)
    },
    getTabAPI(params) {
        return getAPI(this.indexTab, params)
    }
}


// 获取所有的角色
const getAllRoleAPI = () => {
    return getAPI(globalAPI.allReole)
}

// 获取所有的部门

const getAllDeptAPI = () => {
    return getAPI(globalAPI.allDept)
}

//获取所有菜单
const getAllMenuAPI = () => {
    return getAPI(globalAPI.allMenu)
}

//用户管理api
const userAPI = {
    list: '/sys/user/list',//用户数据列表接口
    detele: '/sys/user/delete',//删除用户接口
    status: '/sys/user/status',//用户数据状态，禁用管理
    info: '/sys/user/info/',//用户数据详情接口 /sys/user/info/
    create: '/sys/user/create',//新增用户
    update: '/sys/user/update',//修改用户 
    getList(params) {
        return getAPI(this.list, params)
    },
    changStatus(params) {
        return postAPI(this.status, params)
    },
    deletaFn(id) {
        return postAPI(this.detele, { id })
    },
    createFn(param) {
        return postAPI(this.create, param)
    },
    upDataAPI(param) {
        return postAPI(this.update, param)
    },
    getDateInfo(id) {
        return getAPI(this.info + id)
    }
}

//角色管理api
const roleAPI = {
    list: '/sys/role/list',//用户数据列表接口
    detele: '/sys/role/delete',//删除用户接口
    status: '/sys/role/status',//用户数据状态，禁用管理
    info: '/sys/role/info/',//用户数据详情接口 /sys/user/info/
    create: '/sys/role/create',//新增用户
    update: '/sys/role/update',//修改用户 
    getList(params) {
        return getAPI(this.list, params)
    },
    changStatus(params) {
        return postAPI(this.status, params)
    },
    deletaFn(id) {
        return postAPI(this.detele, { id })
    },
    createFn(param) {
        return postAPI(this.create, param)
    },
    upDataAPI(param) {
        return postAPI(this.update, param)
    },
    getDateInfo(id) {
        return getAPI(this.info + id)
    }
}
//菜单管理APi
const menuAPI = {
    list: '/sys/menu/all',//用户数据列表接口
    detele: '/sys/menu/delete',//删除用户接口
    info: '/sys/menu/info/',//用户数据详情接口 /sys/user/info/
    createCatalog: '/sys/menu/createCatalog',//新增用户
    createMenu: '/sys/menu/createMenu',//新增用户
    update: '/sys/menu/updateMenu',//修改用户 
    getList(params) {
        return getAPI(this.list, params)
    },
    changStatus(params) {
        return postAPI(this.status, params)
    },
    deletaFn(id) {
        return postAPI(this.detele, { id })
    },
    createCatalogFn(param) {
        return postAPI(this.createCatalog, param)
    },
    createMenuFn(param) {
        return postAPI(this.createMenu, param)
    },
    upDataAPI(param) {
        return postAPI(this.update, param)
    },
    getDateInfo(id) {
        return getAPI(this.info + id)
    }
}
//部门管理API

/**
 * 	 ***部门管理页面****
		 获取部门 list  /sys/dept/all   get
		 参数无
		 
		 删除部门  /sys/dept/delete  post
		  'id': id
			
		通过id获取部门信息	/sys/dept/info/${id}
		 
		 新增部门  /sys/dept/create     post
		 'id': this.id || null,
		 'name': this.dataForm.name,
		 'sort': this.dataForm.sort
		 parentId
		 修改部门  /sys/dept/update   post
		 'id': this.id || null,
		 'name': this.dataForm.name,
		 'sort': this.dataForm.sort
		 parentId
*/
const deptAPI = {
    list: '/sys/dept/all',//用户数据列表接口get
    detele: '/sys/dept/delete',//删除用户接口
    info: '/sys/dept/info/',//用户数据详情接口 /sys/user/info/
    create: '/sys/dept/create',//新增部门
    update: '/sys/dept/update',//修改用户 
    getList() {
        return getAPI(this.list)
    },
    deletaFn(id) {
        return postAPI(this.detele, { id })
    },
    createFn(param) {
        return postAPI(this.create, param)
    },
    upDataAPI(param) {
        return postAPI(this.update, param)
    },
    getDateInfo(id) {
        return getAPI(this.info + id)
    }
}

const logAPI = {
    list: '/sys/log/list',//用户数据列表接口
    getList(params) {
        return getAPI(this.list, params)
    },
}
//
const dictAPI = {
    list: '/sys/dict/list',//用户数据列表接口
    detele: '/sys/dict/delete',//删除用户接口
    info: '/sys/dict/info/',//用户数据详情接口 /sys/user/info/
    create: '/sys/dict/create',//新增用户
    update: '/sys/dict/update',//修改用户 
    getList(params) {
        return getAPI(this.list, params)
    },
    deletaFn(id) {
        return postAPI(this.detele, { id })
    },
    createFn(param) {
        return postAPI(this.create, param)
    },
    upDataAPI(param) {
        return postAPI(this.update, param)
    },
    getDateInfo(id) {
        return getAPI(this.info + id)
    }
}
const loginAPI = data => {
    return postAPI(globalAPI.login, data)
}
// ***医疗服务/随访***
const healthAPI = {
    menuList: '/hosptial/menuList',//获取左侧住院信息列表
    detail: '/hosptial/menuList/detail',// 根据左侧菜单 id 获取住院详情  
    checkList: '/check/menuList',//t获取左侧体检信息列表
    checkDetail: '/check/menuList/detail',// 根据左侧菜单 id 获取体检详情
    areaList: "/getArea",//获取所有的行政区划
    targetList: "/target", //获取所有的门诊类别
    detailList: "/clinc/detail",//门诊列表
    followList:"/follow/list",//随访信息list
    getMenuListAPI() {
        return getAPI(this.menuList)
    },
    getDetailAPI(id) {
        return getAPI(this.detail, { id })
    },
    getCheckListAPI() {
        return getAPI(this.checkList)
    },
    getCheckDetailAPI(id) {
        return getAPI(this.checkDetail, { id })
    },
    getAreaListAPI() {
        return getAPI(this.areaList)
    },
    getTargetListAPI() {
        return getAPI(this.targetList)
    },
    getDetailListAPI(params) {
        return getAPI(this.detailList, params)
    },
    getFollowListAPI(){
        return getAPI(this.followList)
    }
}
const logOutAPI = () => {
    return postAPI(globalAPI.logout)
}
const UpdatePasswordAPI = data => {
    return postAPI(globalAPI.password, data)
}
export {
    getAPI, postAPI, loginAPI, logOutAPI, UpdatePasswordAPI,
    getAllRoleAPI, getAllDeptAPI,
    getAllMenuAPI,
    homeAPI,//首页数据API
    userAPI,//用户数据API
    roleAPI,//角色数据API
    menuAPI,//菜单数据API
    deptAPI,//部门数据API
    logAPI,//日志数据API
    dictAPI,//字典数据API
    healthAPI,//医疗服务数据API
}